/**
 * initialize your data structure here.
 */
var MinStack = function () {
  this.data = []
  this.min = []
}

/**
 * @param {number} x
 * @return {void}
 */
MinStack.prototype.push = function (x) {
  const length = this.min.length
  this.data.push(x)
  if (length) {
    x > this.min[length - 1] ? this.min.push(this.min[length - 1]) : this.min.push(x)
  } else {
    this.min.push(x)
  }
}

/**
 * @return {void}
 */
MinStack.prototype.pop = function () {
  this.min.pop()
  this.data.pop()
}

/**
 * @return {number}
 */
MinStack.prototype.top = function () {
  return this.data[this.data.length - 1]
}

/**
 * @return {number}
 */
MinStack.prototype.getMin = function () {
  return this.min[this.min.length - 1]
}

/**
 * Your MinStack object will be instantiated and called as such:
 * var obj = new MinStack()
 * obj.push(x)
 * obj.pop()
 * var param_3 = obj.top()
 * var param_4 = obj.getMin()
 */
